﻿using System.Threading.Tasks;
using Jinjia.Approve.Entity.Entity.JJFlow.Condition;
using Jinjia.Approve.IRepository.JJFlow;
using Jinjia.Core.UnitOfWork.UnitOfWorkComponent;
using SqlSugar;

namespace Jinjia.Approve.Repository.JJFlow
{
    public class BcstYearlyDraftPlanRepository : IBcstYearlyDraftPlanRepository
    {
        private readonly ISqlSugarClient _db;

        public BcstYearlyDraftPlanRepository(IUnitOfWork unitOfWork)
        {
            _db = unitOfWork.GetDbClient();
        }
        
        public async Task<bcst_yearly_draft_plan_tbl> GetByBizOrderId(string biz_order_id)
        {
            var tryParse = int.TryParse(biz_order_id,out var id);
            if (tryParse)
            {
                var bcstYearlyDraftPlanTbl = await _db.Queryable<bcst_yearly_draft_plan_tbl>()
                    .Where(x => x.id == id)
                    .FirstAsync();
                return bcstYearlyDraftPlanTbl;
            }

            return default;
        }
    }
}